class Solution:
    def isValid(self , s ):
        # write code here
        p=''
        if len(s)==1:
            return False
        for i in s:
            if i=='(' or i=='[' or i=='{':
                p=p+i
            elif p=='':
                return False
            elif i==')' and p[-1]=='(':
                p=p[:len(p)-1]
            elif i==']' and p[-1]=='[':
                p=p[:len(p)-1]
            elif i=='}' and p[-1]=='{':
                p=p[:len(p)-1]
            else:
                return False
        if p=='':
            return True
        else:
            return False